home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / utility.lha / utility / defs.H next >
C/C++ Source or Header  |  1993-08-08  |  1KB  |  47 lines

  1. // Some common definitions.
  2. //
  3. // $Id: defs.H,v 1.1 91/02/21 17:59:04 dag Exp $
  4.  
  5.  
  6. #ifndef DEFS_H
  7. #define DEFS_H
  8.  
  9. typedef unsigned boolean;
  10.  
  11. static const unsigned false = 0;
  12. static const unsigned true = 1;
  13.  
  14. #ifndef nil
  15. #define nil 0
  16. #endif
  17.  
  18. #ifndef NILREF
  19. #define NILREF(type) (*(type *) &0)
  20. #endif
  21.  
  22. #ifndef NAME2
  23. #ifdef __DATE__
  24. #define NAME2(a,b)a ## b
  25. #else
  26. #define NAME2(a,b)a/**/b
  27. #endif
  28. #endif
  29.  
  30. inline int min (int a, int b) { return a < b ? a : b; }
  31. inline float min (float a, float b) { return a < b ? a : b; }
  32. inline double min (double a, double b) { return a < b ? a : b; }
  33.  
  34. inline int max (int a, int b) { return a > b ? a : b; }
  35. inline float max (float a, float b) { return a > b ? a : b; }
  36. inline double max (double a, double b) { return a > b ? a : b; }
  37.  
  38. inline int round (double x) { return x > 0 ? int(x+0.5) : -int(-x+0.5); }
  39.  
  40. inline unsigned min(unsigned x, unsigned y)
  41. { if (x < y) return x; else return y; }
  42.  
  43. inline unsigned max(unsigned  x, unsigned y)
  44. { if (x > y) return x; else return y; }
  45.  
  46. #endif
  47.